#pragma once
#include "Notify.h"
#include "MsgNotify.h"
#include "InviteNotify.h"
#include "InviteResultNotify.h"
#include "ExitChatNotify.h"

static unique_ptr<Notify> create_notify(const json& notify_json){
    switch(notify_json["type"].get<NotifyType>()){
        case MSG_NOTIFY:
            return make_unique<MsgNotify>(notify_json);
        case INVITE_NOTIFY:
            return make_unique<InviteNotify>(notify_json);
        case INVITE_RESULT_NOTIFY:
            return make_unique<InviteResultNotify>(notify_json);
        case EXIT_CHAT_NOTIFY:
            return make_unique<ExitChatNotify>(notify_json);
        default:
            throw runtime_error("Unknown notify type");
    }
}

static unique_ptr<Notify>create_notify(NotifyType type, const string& chat_room_id, const string& content, const string& time, int sender_id, int receiver_id){
    switch(type){
        case MSG_NOTIFY:
            return make_unique<MsgNotify>(sender_id, receiver_id, chat_room_id, content, time);
        case INVITE_NOTIFY:
            return make_unique<InviteNotify>(sender_id, receiver_id, chat_room_id, content, time);
        case EXIT_CHAT_NOTIFY:
            return make_unique<ExitChatNotify>(sender_id, receiver_id, chat_room_id, content, time);
        default:
            throw runtime_error("Unknown notify type");
    }
}
static unique_ptr<Notify>create_notify(NotifyType type, const string& chat_room_id, const string& content, const string& time, int sender_id, int receiver_id, int invite_result){
    return make_unique<InviteResultNotify>(sender_id, receiver_id, chat_room_id, content, time, invite_result);
}